import 'package:flutter/material.dart';
import 'package:module/cjjl_page.dart';
import 'package:module/register.dart';
import 'package:module/wallet_page.dart';
import 'package:module/zfji_page.dart';

import 'const.dart';
import 'login.dart';

class ShouZhiPage extends StatefulWidget {
  const ShouZhiPage({super.key});

  @override
  State<ShouZhiPage> createState() => _ShouZhiPageState();
}

class _ShouZhiPageState extends State<ShouZhiPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text(
          '收支历史',
          style: TextStyle(color: Colors.black),
        ),
        leading: GestureDetector(
          onTap: () {
            Navigator.push(context, MaterialPageRoute(builder: (context) {
              return WalletPage();
            }));
          },
          child: Transform.scale(
            scale: 0.5,
            child: Image.asset(
              'assets/icon_back.png',
            ),
          ),
        ),
        bottom: PreferredSize(
          preferredSize: Size(MediaQuery.of(context).size.width, 64),
          child: Material(
            child: Container(
              color: Constants.bgColor,
              child: Column(
                children: [
                  SizedBox(height: 1, child: Divider()),
                  TabBar(
                    controller: _tabController,
                    labelColor: Colors.black,
                    indicatorPadding: EdgeInsets.symmetric(horizontal: 80),
                    indicator: UnderlineTabIndicator(
                      borderSide:
                          BorderSide(width: 2.0, color: Color(0xFFF98B31)),
                    ),
                    // indicator: BoxDecoration(),
                    tabs: [
                      Tab(
                        text: '充值记录',
                      ),
                      Tab(
                        text: '支付记录',
                      ),
                    ],
                  ),
                  SizedBox(height: 20, child: Divider()),
                ],
              ),
            ),
          ),
        ),
      ),
      body: Container(
        color: Constants.bgColor,
        padding: EdgeInsets.symmetric(
          horizontal: 20,
        ),
        child: TabBarView(
          controller: _tabController,
          children: [CjjlPage(), ZfjlPage()],
        ),
      ),
    );
  }
}
